//
//  YSMineTopView.m
//  Community
//
//  Created by YaSha_Tom on 2018/12/25.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "YSMineTopView.h"
#import "UIImage+ChangeColor.h"

@interface YSMineTopView ()

@property (nonatomic, strong) UIImageView *bakcImageView;

@end

@implementation YSMineTopView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(0, 0, kSCREEN_WIDTH, 200*kHeightScale+kTopHeight);
        [self initUI];
    }
    return self;
}

- (void)initUI {
    UIImage *image = [UIImage imageNamed:@"mine_bg"];
    self.bakcImageView = [[UIImageView alloc]initWithImage:[image imageChangeColor:[UIColor qmui_colorWithHexString:@"F55931"]]];
   
    [self addSubview:self.bakcImageView];
    [self.bakcImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.mas_equalTo(self);
    }];
    
    self.avatarButton = [[UIButton alloc] init];
    self.avatarButton.layer.masksToBounds = YES;
    self.avatarButton.layer.cornerRadius = 37*kHeightScale;
    [self addSubview:self.avatarButton];
    [self.avatarButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(80*kHeightScale+kTopHeight);
        make.centerX.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(74*kWidthScale, 74*kHeightScale));
    }];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.text = @"总经理";
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.avatarButton.mas_bottom).offset(10);
        make.centerX.mas_equalTo(self.mas_centerX);
        make.height.mas_equalTo(16*kHeightScale);
        make.width.mas_greaterThanOrEqualTo(0);
    }];
    
    
    [self.avatarButton setImage:[UIImage imageNamed:@"头像"] forState:UIControlStateNormal];
}

@end
